<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\OrderHistory;

class MakeController extends Controller
{
	   // 检测用户是否登录，无登录跳转到登录页面
    public function __construct()
    {
       $this->middleware('auth');
    }
    //已预约订单列表
    public function index(){

    	//取出订单
		$order = OrderHistory::where('order_status','已预约')
								->LeftJoin('serves','order_histories.sid','=','serves.id')
								->select('order_histories.*','serves.title','serves.commit','serves.path')
								->OrderBy('id','desc')
                                ->paginate(5);

    	return view('staticpages.order.make',compact('order'));
    }

    //已服务
    public function edit($id){

        //修改服务状态
        $status = OrderHistory::where('id',$id)->update(['serve_status'=>1]);

        //判断是否修改成功
        if($status){

             return back();
        }
    }
}
